//
//  sendFirCirNewNews.m
//  tcpoctest
//
//  Created by gump on 5/9/13.
//  Copyright (c) 2013 gump. All rights reserved.
//

#import "sendFirCirNewNews.h"

@implementation sendFirCirNewNews

-(void)SendFCNewNews:(char)stindex withContent:(NSString *)strcontent
{
    //发送 74char(1),1char(1),区分值char(1)1文字\2语音,二进制数据长度int，二进制数据char(x)
    
    if (![self CheckLogin]) {
        return;
    }
    
    switch (stindex) {
        case FCG_ONE_TEXT:
        {
            const char *textchar = [strcontent UTF8String];
            int l = CHAR_PL * 3 + INT_PL * 2 + strlen(textchar);
            
            [self initDataByLength:l];
            
            [sb WriteChar:stindex];
            [sb WriteInt:strlen(textchar) withNTT:NTT_SMALL2BIG];
            [sb WriteString:strcontent withLength:strlen(textchar)];
        }
            break;
        case FCG_ONE_SOUND:
        {
            NSData *voicedata = [NSData dataWithContentsOfFile:strcontent];
            int l = CHAR_PL * 3 + INT_PL * 2 + [voicedata length];
            
            [self initDataByLength:l];
            
            [sb WriteChar:stindex];
            [sb WriteInt:[voicedata length] withNTT:NTT_SMALL2BIG];
            [sb WriteData:(char *)[voicedata bytes] withLength:[voicedata length]];
        }
            break;
        default:
            break;
    }
    
    [self Package];
}

@end
